//必须带done回调 执行完成调用
export default function tableRightMenuEnabled({ vm, action, done }) {
  let tableId = action.extension.moduleId.value && action.extension.moduleId.value[0]
  const disabledMenuList = action.extension.menuList.value
  if (tableId && vm.vuiComponents) {
    let _table = vm.vuiComponents[tableId]
    console.log('tableId ------- ', _table)
    console.log('disabledMenuList --------- ', disabledMenuList)
    // 获取到表格配置的右键菜单
    const tableMenuList = _table.self.info.extension.menuConfig && _table.self.info.extension.menuConfig.value
    const disabledMenuFunc = (menuList) => {
      menuList.forEach((item) => {
        disabledMenuList.forEach((disabledItem) => {
          if (disabledItem === item._id) {
            item.disabledByAction = false
          }
        })

        if (item.children) {
          disabledMenuFunc(item.children)
        }
      })
    }
    if (tableMenuList) {
      disabledMenuFunc(tableMenuList)
    }
    done(null, {})
  } else {
    done(null, {})
  }
}
